package com.choosefine.it.basedata.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.choosefine.it.base.BaseService;
import com.choosefine.it.basedata.dao.UserRoleMapper;
import com.choosefine.it.basedata.model.UserRole;
import com.choosefine.it.common.utils.PagedResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class UserRoleService {

	@Autowired
	UserRoleMapper userRoleMapper;
	
	public int deleteByPrimaryKey(Integer id) {
		return userRoleMapper.deleteByPrimaryKey(id);
	}

	public int insert(UserRole record) {
		return userRoleMapper.insert(record);
	}

	public int update(UserRole record) {
		return userRoleMapper.updateByPrimaryKey(record);
	}


	public UserRole findByPrimaryKey(Integer id) {
		return userRoleMapper.selectByPrimaryKey(id);
	}
	
	public List<UserRole> findByUuid(String uuid) {
		return userRoleMapper.selectByUuid(uuid);
	}

	public PageInfo<UserRole> findAllByPage(Map<String, Object> t,
			Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null?1:pageNo;
		pageSize = pageSize == null?10:pageSize;
		PageHelper.startPage(pageNo,pageSize);  //startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		return PagedResult.toPageInfo(userRoleMapper.getUserRoleList());
	}

}
